import moment from "moment"
import { getComponentListByKeys } from "../lib/utils"
import mixin from "./mixin"
// 定义一个混入对象
const customMixin = {
  data(){
    return {
      option: null,
      isLoading: false
    }
  },
  props: {
    ...mixin.props,
  },
  methods: {
    ...mixin.methods,


  },
  created(){
    this.getOptions()
  },
  watch: {
    updateComponent(){
      this.getOptions()
    },
    updateComponentTitle(){
      this.updateTitle()
    },
    'element.style.width': function (){
      this.$refs.widget?.resize()
    },
    'element.style.height': function (){
      this.$refs.widget?.resize()
    },
    'element.style.widthUnit': function (){
      this.$refs.widget?.resize()
    },
    'element.style.heightUnit': function (){
      this.$refs.widget?.resize()
    }
  },
  destroyed(){
    // 组件销毁时
    // 找到绑定该组件的所有过滤组件
    const componentList = getComponentListByKeys(this.$store.state.lowCode.canvasComponentList, this.filterKeys)
    componentList.forEach(element => {
      // 清空过滤组件的筛选字段
      element.props.filterField = [] // []
      // 清空过滤组件的默认值
      element.props.value = undefined
      // 清空过滤组件默认值的options
      element.props.options = []
    })
  }
}

export default customMixin
